const mongoose = require("mongoose");
const ComponentConfig = require("../models/componentconfig");
const router = require("koa-router")();

router.post("/all", async (ctx) => {
  ctx.body = await ComponentConfig.find({});
});

router.post("/detail", async (ctx) => {
  let data = ctx.request.body;
  let findResult = await ComponentConfig.findOne({ name: data.name });
  if (findResult) {
    ctx.body = findResult;
  } else {
    ctx.status = 500;
    ctx.body = { msg: "未定义的组件（无组件配置）" };
  }
});
module.exports = router;
